package com.iversonx.decorator.example_1.service.v2.calculator;

import com.iversonx.decorator.TempDB;
import com.iversonx.decorator.example_1.service.v2.PrizeCalculator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

public class MonthPrizeCalculator implements PrizeCalculator {
    private final Logger logger = LoggerFactory.getLogger(MonthPrizeCalculator.class);

    private final PrizeCalculator prizeCalculator;
    public MonthPrizeCalculator(PrizeCalculator prizeCalculator) {
        this.prizeCalculator = prizeCalculator;
    }
    @Override
    public BigDecimal calc(String user) {
        BigDecimal prize = prizeCalculator.calc(user);
        BigDecimal monthPrize = TempDB.MONTH_SALE_MONTY.get(user).multiply(new BigDecimal("0.03"));
        logger.info("{}当月业务奖金:{}", user, monthPrize);
        return prize.add(monthPrize);
    }
}
